import { observable, action, autorun,toJS } from 'mobx';
import {WeaTableNew,WeaForm} from 'comsMobx'
const {TableStore} = WeaTableNew;
import { ListStore } from './listStore';
import {Modal} from 'antd';
import {WeaTools} from "ecCom"
import * as  Apis from '../apis/report';

export default class CptFlowConditionStore  extends ListStore{	
    title = "流转情况";
    @observable rightMenu =[];

    @observable verified = false;
    @observable hasRight = false; 
    @observable searchParams = {
        reptype:"cptflowreport"
    };

    @action
    initDatas = (params={})=>{
        this.form = new WeaForm();
        this.loading = true;
        Apis.getReportCondition({...this.searchParams}).then(data=>{
            this.loading = false;
            if(!data.isright  && typeof(data.isright) !== "undefined"){
                this.hasRight = false;
				this.verified = true;
            }else{
                this.hasRight = true;
                this.verified = true;
                this.title = data.title;
                this.condition = data.condition;
                this.form && !this.form.isFormInit && this.form.initFormFields(data.condition);
            }
        })
    }

    doSearch = (params={}) =>{
        this.loading = true;
        const searchParamsAd = this.form.getFormParams();
        const newParams = { ...this.searchParams, ...searchParamsAd, ...params };
       Apis.getReportList(newParams).then(data=>{
           this.tableStore.getDatas(data.sessionkey,  params.current || 1);
           this.dataKey = data.sessionkey;
           this.rightMenu = data.rightMenus;
           this.loading = false;
       });
    }

    cptFlowExport=(params={})=>{
        const searchParamsAd = this.form.getFormParams();
        const newParams = { ...this.searchParams, ...searchParamsAd, ...params };
        Apis.exportFlowExc(newParams).then(data=>{
            window.location="/weaver/weaver.file.ExcelOut";
        });
    }

    clearStatus = ()=>{
        this.rightMenu =[];
        this.verified = false;
        this.hasRight = false; 
    }
}